package com.hzj.mysqlite;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class EditAct extends ActionBarActivity implements OnClickListener
{
	EditText editText1;
	
	Type type;
	int arrayListPosition;
	
	Button button1;
	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.edit_act);
		editText1 = (EditText) findViewById(R.id.editText1);
		type = (Type) (this.getIntent().getSerializableExtra("type"));
		arrayListPosition=this.getIntent().getIntExtra("arrayListPosition",-1);
		editText1.setText(type.getName());
		
		button1=(Button)this.findViewById(R.id.button1);
		button1.setOnClickListener(this);
	}

	@Override
	public void onClick(View v)
	{
		
		switch (v.getId())
		{
		case R.id.button1:
			button1();
			break;

		default:
			break;
		}
	}

	private void button1()
	{
		
		
		type.setName(editText1.getText().toString());
		
		
		Intent intent=new Intent();
		intent.putExtra("type", type);
		intent.putExtra("arrayListPosition", arrayListPosition);
		
		
		//返回
		this.setResult(2, intent);
		
		
		
		this.finish();	
	}

}
